<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php
include_once("conn.php");
$sql = "SELECT * FROM xuanke WHERE `sid` = '$id'";
$result=mysql_query($sql);
while($row = mysql_fetch_row($result)){
	$hasTaken[]=$row[2];
}
getNotTakenCourse($hasTaken);
mysql_close($conn);

function getNotTakenCourse($hasTaken){
	$sql = "SELECT * FROM course WHERE";
	foreach ($hasTaken as $value){
		$sql.=" `id` !=$value AND";
	}
	$sql = substr($sql,0,strlen($sql)-4);
	$result=mysql_query($sql);
	echo "<form id=\"form1\" name=\"form1\" method=\"post\" action=\"dotake.php\">";
	while($row = mysql_fetch_row($result)){
?>
<table width="50%" border="1" bordercolor="#ffffff" bgcolor="#6589d1" class="h" style="BORDER-COLLAPSE: collapse color: #FFF color: #FFF ">
  <tr>
    <td>
      <label>
        <input type="checkbox" name="course[]" value="<?=$row[0]?>"/>
      </label>
    </td>
    <td>课程号<?php echo " :".$row[0]; ?></td>
    <td>课程名<?php echo " :".$row[1]; ?></td>
    <td>学分<?php echo " :".$row[2]; ?></td>
    <td>所属专业<?php echo " :".$row[3]; ?></td>
  </tr>
  <tr>
    <td colspan="5" bgcolor="#FFFFFF">&nbsp;</td>
  </tr>
</table>
<p>&nbsp;</p>
  <p>
    <?php
	}
	echo "<label><input type=\"submit\" name=\"submit\" id=\"submit\" value=\"提交\" /></label>";
	echo "</form>";
}
?>
</p>
</body>
</html>